﻿@model KL.Store.Web.Models.ActiveAccountModel
@using KL.Store.Core
@{
    Layout = null;
    bool hasFacebookLogin = !string.IsNullOrEmpty(Parameters.FaceBookAppId);
    bool hasTwitterLogin = !string.IsNullOrEmpty(Parameters.TwitterAppId);
}
@if (Parameters.Theme == "BT")
{
    if (Request.IsAuthenticated && Model.StoreUserId > 0)
    {
    <a data-original-title="Çıkış Yap" data-placement="bottom" rel="tooltip" class="logout" title="" href="@Url.Content("~/Account/LogOff")"><span><i class="icon-lock"></i></span></a>

    }
    else
    {
    <a data-original-title="Giriş Yap" data-placement="bottom" rel="tooltip" class="login" title="" href="@Url.Content("~/Account/Login")"><span><i class="icon-unlock"></i></span></a>
    }
}
else if (Parameters.Theme == "JJ" || Parameters.Theme == "JB")
{
    if (Request.IsAuthenticated && Model.StoreUserId > 0)
    {
    <ul class="right">
        <li>Hoşgeldiniz, <a href="@Url.Content("~/Account/Index")">@(string.IsNullOrEmpty(Model.StoreUserName) ? "Hesabınız" : Model.StoreUserName)</a></li>
        <li><a href="@Url.Content("~/Account/LogOff")">Çıkış Yap</a></li>
    </ul>  
    }
    else
    {
    <div id="fb-root">
    </div>
    <ul class="right">
        <li>Hoşgeldiniz. <a href="@(Parameters.WebSiteSecureUrl)/Account/Login">Üye Girişi</a> <span class="hidden-sm hidden-md hidden-lg">|</span><span class="hidden-xs">yapın ya da</span> <a href="@(Parameters.WebSiteSecureUrl)/Account/Register">Üye Olun</a></li>
        @if (hasFacebookLogin)
        {
            <script type="text/javascript">
                window.fbAsyncInit = function ()
                {
                    FB.init({
                        appId: '@(Parameters.FaceBookAppId)',
                        status: true,
                        cookie: true,
                        xfbml: true,
                        oauth: true
                    });

                    function updateButton(response)
                    {
                        var button = document.getElementById('BtnFBLogin');
                        button.onclick = function ()
                        {
                            FB.login(function (response)
                            {
                                if (response.authResponse)
                                {
                                    FB.api('/me', function (response)
                                    {
                                        var userID = FB.getAuthResponse()['userID'];
                                        var accessToken = FB.getAuthResponse()['accessToken'];
                                        var signedRequest = FB.getAuthResponse()['signedRequest'];
                                        if (accessToken != "")
                                        {
                                            window.location = "@(Url.Action("FacebookLogin", "OAuth"))?token=" + accessToken;
                                        }
                                    });
                                } else
                                {

                                }
                            }, { scope: 'email' });

                            return false;
                        }
                    }
                    FB.getLoginStatus(updateButton);
                    FB.Event.subscribe('auth.statusChange', updateButton);
                };

                $(document).ready(function ()
                {
                    if (document.getElementById('fb-root') != undefined)
                    {
                        var e = document.createElement('script');
                        e.type = 'text/javascript';
                        e.src = document.location.protocol + '//connect.facebook.net/tr_TR/all.js';
                        e.async = true;
                        document.getElementById('fb-root').appendChild(e);
                    }
                });
            </script>
            <li>
                <a href="#" id="BtnFBLogin">
                    <img id="fb-ile-baglan" src="/Images/@(Parameters.Theme)/fb-ile-baglan.png" alt="FB" />&nbsp;<span class="hidden-xs">ile</span> bağlan
                </a>
            </li>
        }
    </ul>
    }
}
else if (Parameters.Theme == "HA")
{
    if (Request.IsAuthenticated && Model.StoreUserId > 0)
    {
    <ul class="right loginMenu">
        <li>Hoşgeldiniz, <a href="@Url.Content("~/Account/Index")">@(string.IsNullOrEmpty(Model.StoreUserName) ? "Hesabınız" : Model.StoreUserName)</a></li>
        <li><a href="@Url.Content("~/Account/LogOff")">Çıkış Yap</a></li>
    </ul>  
    }
    else
    {
    <div id="fb-root">
    </div>
    <ul class="right loginMenu">
        <li class="header-phone">@Parameters.PrimaryPhoneNumber</li>
        <li class="standart"><a href="@(Parameters.WebSiteSecureUrl)/Account/Login">KAYDOL / GİRİŞ YAP</a></li>
        @if (hasFacebookLogin)
        {
            <script type="text/javascript">
                window.fbAsyncInit = function ()
                {
                    FB.init({
                        appId: '@(Parameters.FaceBookAppId)',
                        status: true,
                        cookie: true,
                        xfbml: true,
                        oauth: true
                    });

                    function updateButton(response)
                    {
                        var button = document.getElementById('BtnFBLogin');
                        button.onclick = function ()
                        {
                            FB.login(function (response)
                            {
                                if (response.authResponse)
                                {
                                    FB.api('/me', function (response)
                                    {
                                        var userID = FB.getAuthResponse()['userID'];
                                        var accessToken = FB.getAuthResponse()['accessToken'];
                                        var signedRequest = FB.getAuthResponse()['signedRequest'];
                                        if (accessToken != "")
                                        {
                                            window.location = "@(Url.Action("FacebookLogin", "OAuth"))?token=" + accessToken;
                                        }
                                    });
                                } else
                                {

                                }
                            }, { scope: 'email' });

                            return false;
                        }
                    }
                    FB.getLoginStatus(updateButton);
                    FB.Event.subscribe('auth.statusChange', updateButton);
                };

                $(document).ready(function ()
                {
                    if (document.getElementById('fb-root') != undefined)
                    {
                        var e = document.createElement('script');
                        e.type = 'text/javascript';
                        e.src = document.location.protocol + '//connect.facebook.net/tr_TR/all.js';
                        e.async = true;
                        document.getElementById('fb-root').appendChild(e);
                    }
                });
            </script>
            <li class="standart"><a href="#" id="BtnFBLogin">
                <img src="/Images/@Parameters.Theme/facebook-ile-baglan.png" alt="Facebook ile Bağlan" width="82" height="20" /></a></li>
        }
    </ul>
    }
}
else if (Parameters.Theme == "EO")
{
    if (Request.IsAuthenticated && Model.StoreUserId > 0)
    {
    <div class="welcome alignright">
        Merhaba, @Html.ActionLink(string.IsNullOrEmpty(Model.StoreUserName) ? "Hesabınız" : Model.StoreUserName, "Index", "Account") | @Html.ActionLink("Çıkış", "LogOff", "Account")
    </div>
    }
    else
    {
    <div id="fb-root">
    </div>
    <div class="welcome alignright">
        <span>Hoşgeldiniz, </span>
        @if (hasFacebookLogin)
        {
            <script type="text/javascript">
                window.fbAsyncInit = function ()
                {
                    FB.init({
                        appId: '@(Parameters.FaceBookAppId)',
                        status: true,
                        cookie: true,
                        xfbml: true,
                        oauth: true
                    });

                    function updateButton(response)
                    {
                        var button = document.getElementById('BtnFBLogin');
                        button.onclick = function ()
                        {
                            FB.login(function (response)
                            {
                                if (response.authResponse)
                                {
                                    FB.api('/me', function (response)
                                    {
                                        var userID = FB.getAuthResponse()['userID'];
                                        var accessToken = FB.getAuthResponse()['accessToken'];
                                        var signedRequest = FB.getAuthResponse()['signedRequest'];
                                        if (accessToken != "")
                                        {
                                            window.location = "@(Url.Action("FacebookLogin", "OAuth"))?token=" + accessToken;
                                        }
                                    });
                                } else
                                {

                                }
                            }, { scope: 'email' });

                            return false;
                        }
                    }
                    FB.getLoginStatus(updateButton);
                    FB.Event.subscribe('auth.statusChange', updateButton);
                };

                $(document).ready(function ()
                {
                    if (document.getElementById('fb-root') != undefined)
                    {
                        var e = document.createElement('script');
                        e.type = 'text/javascript';
                        e.src = document.location.protocol + '//connect.facebook.net/tr_TR/all.js';
                        e.async = true;
                        document.getElementById('fb-root').appendChild(e);
                    }
                });
            </script>
            <a id="BtnFBLogin" style="cursor: pointer; text-decoration: none;">
                <img src="/Images/@(Parameters.Theme)/fb_connect.png" alt="Facebook ile giriş." />
            </a>
            <text> | </text>
        }
        @if (hasTwitterLogin)
        {
            <script src="//platform.twitter.com/anywhere.js?id=@(Parameters.TwitterAppId)&v=1" type="text/javascript"></script>
            <span id="login-logout"></span>
            <script type="text/javascript">
                jQuery(function ()
                {
                    twttr.anywhere(function (T)
                    {
                        if (T.isConnected())
                        {
                            twttr.anywhere.signOut();
                        }
                        T("#login-logout").connectButton({
                            size: "small",
                            authComplete: function (user)
                            {
                                window.location = "@(Url.Action("TwitterLogin", "OAuth"))?id=" + T.currentUser.attributes.id + '&name=' + T.currentUser.attributes.name;
                            },
                            signOut: function ()
                            {
                                alert('signouted');
                            }
                        });
                    });
                });
            </script>
            <text> | </text>
        }
        <a href="@(Parameters.WebSiteSecureUrl)/Account/Login">Üye Girişi</a> | <a href="@(Parameters.WebSiteSecureUrl)/Account/Register">Üye Ol</a>
    </div>
    }
}
else if (Parameters.Theme == "WU")
{
    if (Request.IsAuthenticated && Model.StoreUserId > 0)
    {
    <div class="tm_headerlinkmenu">
        <ul class="links">
            <li class="first"><a title="Hesabım" href="/Account/Index">Hesabım</a></li>
            <li><a class="top-link-cart" title="Sepetim" href="/Cart/Index">Sepetim</a></li>
            <li class=" last"><a title="Giriş Yap" href="/Account/Logoff">Çıkış Yap</a></li>
        </ul>
    </div>
    <div class="welcome-msg">Merhaba  @Html.ActionLink(string.IsNullOrEmpty(Model.StoreUserName) ? "Hesabınız" : Model.StoreUserName, "Index", "Account")!</div>
    }
    else
    {
    <div class="tm_headerlinkmenu">
        <ul class="links">
            <li class="hidden-xs hidden-sm"><a class="top-link-cart" title="Sepetim" href="/Cart/Index">Sepetim</a></li>
            @if (hasFacebookLogin)
            {
                <script type="text/javascript">
                    window.fbAsyncInit = function ()
                    {
                        FB.init({
                            appId: '@(Parameters.FaceBookAppId)',
                            status: true,
                            cookie: true,
                            xfbml: true,
                            oauth: true
                        });

                        function updateButton(response)
                        {
                            var button = document.getElementById('BtnFBLogin');
                            button.onclick = function ()
                            {
                                FB.login(function (response)
                                {
                                    if (response.authResponse)
                                    {
                                        FB.api('/me', function (response)
                                        {
                                            var userID = FB.getAuthResponse()['userID'];
                                            var accessToken = FB.getAuthResponse()['accessToken'];
                                            var signedRequest = FB.getAuthResponse()['signedRequest'];
                                            if (accessToken != "")
                                            {
                                                window.location = "@(Url.Action("FacebookLogin", "OAuth"))?token=" + accessToken;
                                        }
                                    });
                                } else
                                {

                                }
                            }, { scope: 'email' });

                            return false;
                        }
                    }
                        FB.getLoginStatus(updateButton);
                        FB.Event.subscribe('auth.statusChange', updateButton);
                    };

                $(document).ready(function ()
                {
                    if (document.getElementById('fb-root') != undefined)
                    {
                        var e = document.createElement('script');
                        e.type = 'text/javascript';
                        e.src = document.location.protocol + '//connect.facebook.net/tr_TR/all.js';
                        e.async = true;
                        document.getElementById('fb-root').appendChild(e);
                    }
                });
                </script>
                <li class="standart"><a href="#" id="BtnFBLogin">
                    <img src="/Images/@Parameters.Theme/facebook-ile-baglan.png" alt="Facebook ile Bağlan" width="82" height="20" /></a></li>
            }
            <li><a class="top-link-checkout" title="Giriş Yap" href="/Account/Login">Giriş Yap</a></li>
            <li class=" last"><a title="Kaydol" href="/Account/Register">Kaydol</a></li>
        </ul>
    </div>
    <div class="welcome-msg hidden-xs hidden-sm">Merhaba, Hoşgeldiniz!</div>
    }
}
else
{
    if (Request.IsAuthenticated && Model.StoreUserId > 0)
    {
    <div class="welcome alignright">
        Merhaba, @Html.ActionLink(string.IsNullOrEmpty(Model.StoreUserName) ? "Hesabınız" : Model.StoreUserName, "Index", "Account")<br />@Html.ActionLink("Çıkış", "LogOff", "Account")
    </div>
    }
    else
    {
    <div id="fb-root">
    </div>
    <div class="welcome alignright">
        @if (hasFacebookLogin)
        {
            <script type="text/javascript">
                window.fbAsyncInit = function ()
                {
                    FB.init({
                        appId: '@(Parameters.FaceBookAppId)',
                        status: true,
                        cookie: true,
                        xfbml: true,
                        oauth: true
                    });

                    function updateButton(response)
                    {
                        var button = document.getElementById('BtnFBLogin');
                        button.onclick = function ()
                        {
                            FB.login(function (response)
                            {
                                if (response.authResponse)
                                {
                                    FB.api('/me', function (response)
                                    {
                                        var userID = FB.getAuthResponse()['userID'];
                                        var accessToken = FB.getAuthResponse()['accessToken'];
                                        var signedRequest = FB.getAuthResponse()['signedRequest'];
                                        if (accessToken != "")
                                        {
                                            window.location = "@(Url.Action("FacebookLogin", "OAuth"))?token=" + accessToken;
                                        }
                                    });
                                } else
                                {

                                }
                            }, { scope: 'email' });

                            return false;
                        }
                    }
                    FB.getLoginStatus(updateButton);
                    FB.Event.subscribe('auth.statusChange', updateButton);
                };

                $(document).ready(function ()
                {
                    if (document.getElementById('fb-root') != undefined)
                    {
                        var e = document.createElement('script');
                        e.type = 'text/javascript';
                        e.src = document.location.protocol + '//connect.facebook.net/tr_TR/all.js';
                        e.async = true;
                        document.getElementById('fb-root').appendChild(e);
                    }
                });
            </script>
            <div style="display: inline">
                <a id="BtnFBLogin" style="cursor: pointer; text-decoration: none;">
                    <img src="/Images/@(Parameters.Theme)/fb_connect.png" alt="Facebook ile giriş." style="margin-bottom:-5px" />
                </a>/
            </div>
        }
        @if (hasTwitterLogin)
        {
            <script src="//platform.twitter.com/anywhere.js?id=@(Parameters.TwitterAppId)&v=1" type="text/javascript"></script>
            <span id="login-logout"></span>
            <script type="text/javascript">
                jQuery(function ()
                {
                    twttr.anywhere(function (T)
                    {
                        if (T.isConnected())
                        {
                            twttr.anywhere.signOut();
                        }
                        T("#login-logout").connectButton({
                            size: "small",
                            authComplete: function (user)
                            {
                                window.location = "@(Url.Action("TwitterLogin", "OAuth"))?id=" + T.currentUser.attributes.id + '&name=' + T.currentUser.attributes.name;
                            },
                            signOut: function ()
                            {
                                alert('signouted');
                            }
                        });
                    });
                });
            </script>
            <text>/</text>
        }
        <a href="@(Parameters.WebSiteSecureUrl)/Account/Login">Üye Girişi</a><br />
        <a href="@(Parameters.WebSiteSecureUrl)/Account/Register">Üye Ol</a>
    </div>
    }
}
@if (Request.IsAuthenticated && Model.StoreUserId > 0)
{
    <div id="fb-root"></div>
    <script>(function (d, s, id)
{
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
}